Ext.define('PHT.CheckBatchLogPanel', {
    extend: 'Ext.panel.Panel',
    alias: ['widget.chkbatchlogpanel'],

    layout: {
        columns: 2,
        type: 'table'
    },
    flex: 2,

    initComponent: function() {
        var me = this;
        
        var batchlogServerStore = Ext.create('Ext.data.Store', {
            model: 'PHT.MODEL.Item',   
            proxy: {
                type: 'ajax',
                url : 'initBatchlogserver.do?n='+ new Date(),
                reader: {
                    type: 'json',
                    root: 'names'
                }
            },
            autoLoad: true
        });
        
        var batchLogStore = Ext.create('Ext.data.Store', {
            model: 'PHT.MODEL.Item',   
            proxy: {
                type: 'ajax',
                url : 'initBatchLog.do?n='+ new Date(),
                reader: {
                    type: 'json',
                    root: 'names'
                }
            },
            autoLoad: false
        });

        Ext.applyIf(me, {
            items: [
                {
                    xtype: 'combobox',
                    id: 'log-server',
                    margin: '30,0,0,60',
                    store: batchlogServerStore,
                    displayField: 'name',
                    valueField: 'id',
                    //forceSelection: true,
                    triggerAction: 'all',
                    queryMode: 'local',
                    typeAhead: true,
                    emptyText : 'Select a Log server name',
                    listeners:{   
                        select:function(combo,record,index){
                             try{
                                 var lognames = Ext.getCmp('log');
                                 //var batchlogserver = Ext.getCmp('log-server');
                                 lognames.clearValue();
                                 lognames.store.load({params:{serverid:this.value}});
                             }catch(ex){
                                 Ext.MessageBox.alert("error","load data fail!");
                             }
                        }
                    } 
                },
                {
                    xtype: 'button',
                    text: 'Disconnect'
                },
                {
                    xtype: 'label',
                    margin: '30,0,0,60',
                    text: 'batch log',
                    colspan: 2
                },
                {
                    xtype: 'combobox',
                    id: 'log',
                    margin: '30,0,0,60',
                    store: batchLogStore,
                    colspan: 2,
                    displayField: 'name',
                    valueField: 'id',
                    emptyText : 'Select a Log name',
                    triggerAction: 'all',
                    queryMode: 'local',
                    typeAhead: true,
                    //allowBlank: false,
                    blankText : 'Select a server name first',                    
                },
                {
                    xtype: 'button',
                    margin: '30,0,0,60',
                    text: 'Check Batch Log'
                }
            ]
        });

        me.callParent(arguments);
    }
});